﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XVUEfxSDK.Xsequencer;
using XVUEfxSDK.Xplugin;
using XVUEfxSDK.Xplugin.Xuserinterface;
namespace SamplesCSharp.AdvancedPlugins
{
    [XvuePluginUIInfo(AuthorName="Angel",CompanyName = "XVUE",PluginName = "Sample plugin Hello world")]
    public partial class HelloWorldAdvanced :xvuePluginUI 
    {
        public HelloWorldAdvanced()
        {
            InitializeComponent();
        }

        public override string ToString()
        {
            return "Sample plugin Hello world";
        }

        public override IXvueSequencerUser xSequencer
        {
            get
            {
                return base.xSequencer;
            }
            //do here any initializations or closing
            set
            {
                base.xSequencer = value;
                textBox1.Enabled = false;
            }
        }

        //every time a text box change happens change the text using the swap effect
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            ChangeText(textBox1.Text);
        }

        void ChangeText(string cs)
        {
            XvueSequencerItemTextBase text = new XvueSequencerItemTextBase();
            //this line of code indicates that this text targets swap1 effect
            //it will automatically exchange old text item with this new one
            text.XvParentEffectTAG = "swap1";

            text.xText = cs;
            text.xFontFamily = "Arial";
            text.xSize = 35;
            text.xVisualProperties.xPosition.X = 100;
            text.xVisualProperties.xPosition.Y = 300;
            text.xPalette.ColorForeground = Color.FromArgb(255, 250, 250, 200);
            xSequencer.xQueSequencerItem(text);
        }

        private void buttonPrepare_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = true;

            xSequencer.xCommand("XVUE", XvueSequencerCommandType.ClearAllItems);
            
            XvueSequencerSwapBase swap = new XvueSequencerSwapBase();
            swap.XvEffectTAG = "swap1";
            xSequencer.xQueSequencerItem(swap);

            ChangeText(textBox1.Text);
        }

    }
}
